package aufgabe2;

import java.util.*;

/**
 * definition of a Teacher
 * 
 * @author Lukas Koell
 * @author David Medenjak
 * @author Johannes Riedmann
 */
public class Teacher extends User {
    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    /** the courses that this teacher teaches on **/
    private HashMap<Integer, Subscribeable> courses;

    /** social insurance number **/
    private int svNr;

    public Teacher(int svNr) {
        super();
        courses = new HashMap<Integer, Subscribeable>();
        this.svNr = svNr;
    }

    public int getId() {
        return svNr;
    }

    /**
     * adds a course to the teacher to keep track of where he is teaching
     * 
     * @param course
     *            the course to add
     */
    public void addCourse(Subscribeable course) {
        courses.put(course.getId(), course);
    }

    public String toString() {
        return this.getName();
    }

    /**
     * when a teacher is updated by an observable, only TeacherNotifications
     * will be handled. Everything else will be ignored
     */
    public void update(Observable o, Object arg) {
        if (arg instanceof TeacherNotification) {
            notifications.add(arg.toString());
        }
    }
}
